<?php
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */

declare (strict_types=1);

namespace Newbie\Abstracts;

use Newbie\NewbieModel;
use Newbie\Traits\MapperTrait;

/**
 * Class AbstractMapper
 * @package Newbie\abstracts
 */
abstract class AbstractMapper {
    use MapperTrait;

    /**
     * @var NewbieModel
     */
    public $model;

    abstract public function assignModel ();

    public function __construct () {
        $this->assignModel();
    }

    /**
     * 把数据设置为类属性
     * @param array $data
     */
    public static function setAttributes (array $data) {

    }

    /**
     * 魔术方法，从类属性里获取数据
     * @param string $name
     * @return mixed|string
     */
    public function __get (string $name) {
        return $this->getAttributes()[$name] ?? '';
    }

    /**
     * 获取数据
     * @return array
     */
    public function getAttributes (): array {
        return [];
    }
}
